<html>
<head>
<script>

function log(str)
{
    var li = document.createElement("li");
    li.appendChild(document.createTextNode(str));
    var console = document.getElementById("console");
    console.appendChild(li);
}

function runTest()
{
    if (window.testRunner)
        testRunner.dumpAsText();

    if (!window.eventSender)
        return;

    var textarea = document.getElementById("test");

    // set the cursor several characters into the first line of the text area so
    // that when you go down by a line, the cursor will be at the end of the
    // numbered lines:
    textarea.setSelectionRange(5, 5);
    textarea.focus();
    for (var i = 0; i < 10; i++) {
        // press the 'down arrow' a bunch of times to try to get to the end of the text area
        eventSender.keyDown("ArrowDown");
    }
    if (textarea.selectionStart != textarea.value.length)
        log("Fail.  Expected: selectionStart == " + textarea.value.length + ", Found: " + textarea.selectionStart);
    else
        log("Success");
}

</script>

</head>
    <body onload="runTest()">
        <p>
        This tests that the cursor doesn't get 'stuck' when advancing through a
        text area with the down arrow key.  See bug #19465 for more information
        </p>
        <p>
        If the test is successful and the cursor is at the end of the textarea, you should see the word 'Success' printed below
        </p>
<textarea id="test" rows="10" cols="80">What steps will reproduce the problem?
1. 
2. 
3. 

What is the expected output? What do you see instead?</textarea>

<ul id="console"></ul>

    </body>
</html>
